Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mercenary #1448

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Mercenary #1448

wants to merge 9 commits into from

Conversation

MikeKGilmore
Copy link

Highlights:

  • Ability to hire a specific merc type of specific variant (i.e. Act2, Holy Freeze, Act3, Fire)
  • Improved ability to detect merc, determine if it is dead, etc
  • Checks quests to ensure that Mercs can be hired at the appropriate time (useful when smurfing)
  • Safely and reliably get your bot's mercenary via Mercenary.getMerc();

To specify which merc to use, modify config as follows:
Config.UseMerc={mercType: 1, variant: 11};

mercType is set to the act# - for example, 1 for act 1 rogue merc, 5 for act 5 barb
variant is set to the skill (see sdk/skills.txt) that you want your merc to have - in this case 11 for cold arrow.
Variant can be omitted if you don't care which skill the merc has.

Notes:

  • When attempting to hire a merc of a specific variant, the bot will keep hiring until the desired variant is obtained. Be sure that your merc has enough funds when attempting to hire a merc, especially in higher difficulties or at higher levels

@noah-
Copy link
Collaborator

noah- commented Apr 13, 2019

can you run the code through eslint

@MikeKGilmore
Copy link
Author

Ran esLint - it didn't detect any issues other than not being able to find certain symbols (like Config/Town/Misc/me/print()/etc).

@noah-
Copy link
Collaborator

noah- commented Apr 14, 2019

well there seems to be lots of white space / new line issues in mercenary.js
for example, line 38, 42, 59, 71, 95 etc
inconsistent comment spacing, line 98
switch case at line 135
many more

are you using the eslint settings for kolbot provided in the readme or some random one?

@MikeKGilmore
Copy link
Author

Sorry, you're right, I missed the eslint configs from the readme. I re-ran and fixed them.

@MikeKGilmore
Copy link
Author

Checked in a fix but somehow other stuff got rolled up into the push. I'll have to fix it.

@MikeKGilmore
Copy link
Author

Removed commits that didn't belong in this PR.

Copy link
Collaborator

@noah- noah- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

d2bs/kolbot/libs/common/Town.js Show resolved Hide resolved
d2bs/kolbot/libs/common/Mercenary.js Outdated Show resolved Hide resolved
d2bs/kolbot/libs/common/Mercenary.js Outdated Show resolved Hide resolved
d2bs/kolbot/libs/common/Mercenary.js Outdated Show resolved Hide resolved
d2bs/kolbot/libs/common/Mercenary.js Outdated Show resolved Hide resolved
d2bs/kolbot/libs/common/Mercenary.js Show resolved Hide resolved
d2bs/kolbot/libs/common/Mercenary.js Outdated Show resolved Hide resolved
throw new Error("Mercenary.hire: args.mercType is required");
}

if (args.mercType < 1 || args.mercType === 4 || args.mercType > 5) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this check done before, maybe change mercType to a get/set that auto validates the input so you don't need to sanitize it every time

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that I understand what you mean by this or how you propose that it would be used.

d2bs/kolbot/libs/common/Mercenary.js Outdated Show resolved Hide resolved
d2bs/kolbot/libs/common/Mercenary.js Outdated Show resolved Hide resolved
@mf022 mf022 mentioned this pull request May 14, 2019

switch (mercType) {
case 1:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra new line

}

break;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need newlines after breaks

if (args.variant === v) {
break;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove new line

}

me.cancel();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove new line

print("No mercs available");

me.cancel();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove new line

revive: function () {
if (!this.needMerc()) {
print("I don't need to revive my merc");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove new line

while (getTickCount() - tick < 2000) {
if (this.getMerc()) {
delay(Math.max(750, me.ping * 2));

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove new line

print("Unloading merc equipment");
var cursorItem;

// ok this is a bit stupid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you turn this into a loop that goes 4, 3, 1 since the code just repeats?


delay(1000 + me.ping * 2);

removeEventListener("gamepacket", this._gamePacket);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is _gamePacket?


mercPacket: function (bytes) {
if (bytes[0] !== 0x4e) {
return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any way to get available mercs without using packets?
possibly by parsing the list?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants